import request from '@/utils/request'
import { AxiosPromise } from 'axios'
import { RefundBo, RefundQueryBo } from '@/api/business/refund/types'

enum Api {
  list = '/refund/list',
  remove = '/refund/remove',
  batchRemove = '/refund/batchRemove',
  add = '/refund/add',
  refund = '/refund/refund',
  detail = '/refund/detail',
}

// 获取列表
export const list = (data): AxiosPromise<any> => {
  return request({
    url: Api.list,
    method: 'post',
    data,
  })
}

// 删除
export const remove = (data: string) => {
  return request({
    url: Api.remove,
    method: 'post',
    data,
  })
}
// 批量删除
export const batchRemove = (data: (string | number)[]) => {
  return request({
    url: Api.batchRemove,
    method: 'post',
    data,
  })
}

// 编辑、保存
export const add = (data: RefundBo) => {
  return request({
    url: Api.add,
    method: 'post',
    data,
  })
}

// 退款
export const refund = (data: string) => {
  return request({
    url: Api.refund,
    method: 'post',
    data,
  })
}

// 详情
export const detail = (data: RefundQueryBo) => {
  return request({
    url: Api.detail,
    method: 'post',
    data,
  })
}
